package com.freedom.admin.infrastructure.persistence.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.freedom.admin.infrastructure.persistence.pojo.bo.PermissionBO;
import com.freedom.admin.infrastructure.persistence.pojo.po.SysPermissionPO;
import com.freedom.admin.infrastructure.persistence.pojo.query.PermissionPageQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Set;

@Mapper
public interface SysPermissionMapper extends BaseMapper<SysPermissionPO> {
    /**
     * 权限<->有权限的角色集合
     *
     * @return
     */
    List<PermissionBO> listPermRoles();

    /**
     * 根据角色编码集合获取按钮权限
     *
     * @param roles
     * @return
     */
    List<String> listBtnPermByRoles(@Param("roles") Set<String> roles);


    Page<PermissionBO> selectPermissionPage(Page<PermissionBO> page, @Param("queryParams") PermissionPageQuery queryParams);

    List<SysPermissionPO> selectPermissions(@Param("menuId") Integer menuId);

    Boolean updatePermission(SysPermissionPO sysPermissionPO);

    Boolean insertPermission(SysPermissionPO sysPermissionPO);
}
